////////////////////////////////////////////////////////////////////////////////////
//                                                                                                                                //
//                    Sequence list's find, insert, delete, etc...functions' implemention code               //
//                                                                                                                                //
//                                                                                                                                //
//                        Author:    Jack Hui (huiguobin)                                                               //
//                                                                                                                                //
//                                                                                                                                //
////////////////////////////////////////////////////////////////////////////////////

///////////////////////////////Test File//////////////////////////////////////////////

//#define switch

#ifdef switch

#include "sequence_list.h"

int main()
{
	SeqList L;
	L.size = 6;
	L.data[0] = 1;
	L.data[1] = 2;
	L.data[2] = 3;
	L.data[3] = 4;
	L.data[4] = 5;
	L.data[5] = 6;

	printf("The init list is:\n");
	print_seq(L);
	

	/*Test Sequence List's find function.*/
	DataType finding_data = 6;
	int found_pos = 0;
	int rtn = find_seq(L, finding_data,  found_pos);
	if(0 == rtn)
	{
		printf("find_error!\n");
		goto INSERT_TEST;
	}

	printf("the found pos is: %d\n", found_pos);
	print_seq(L);


INSERT_TEST:
	
	/*Test Sequence List's insert function.*/
	DataType sert_data = 1984;
	int insert_pos = 3;
	rtn = insert_seq(L, insert_pos,  sert_data);
	if(0 == rtn)
	{
		printf("insert_error!\n");
		goto DELETE_TEST;
	}

	printf("the size now is: %d\n", L.size);
	print_seq(L);


DELETE_TEST:

	/*Test Sequence List's delete function.*/
	DataType de_data = 0;
	int de_pos = 4;
	rtn = delete_seq(L, de_pos,  de_data);
	if(0 == rtn)
	{
		printf("insert_error!\n");
		goto REVERSE_TEST;
	}

	printf("the deleted data is: %d\n", de_data);
	printf("the size now is: %d\n", L.size);
	print_seq(L);

REVERSE_TEST:

	/*Test Sequence List's reverse_seq function.*/
	printf("before reverse, the list sequence is: \n");
	print_seq(L);

	rtn = reverse_seq(L);
	if(0 == rtn)
	{
		printf("reverse_error!\n");
	}
	
	printf("after reverse, the list sequence is: \n");
	print_seq(L);
	
	return 0;
}

#endif
